﻿using System;
using System.Collections.Generic;
using System.Data;
using Demo.CommonBase.Integration.DAO.Impl;
using Demo.Services.Contracts.DTO.Infos;
using System.Data.SqlClient;
using Demo.CommonBase.Logging;
using Demo.Services.Integration.DAO.Contracts.Exceptions;
using System.Reflection;
using Demo.CommonBase.Exceptions;
using Demo.Services.Integration.DAO.IntegrationComponents.Mappings;

namespace Demo.Services.Integration.DAO.Impl
{
    public class DemoDAO : DAOBase
    {
        public IList<ContactInfo> GetContacts()
        {
            IList<ContactInfo> contactos=null;
            try
            {
                DataSet ds = Retrieve("Contact_R");
                if (ValidateDataSet(ds))
                {
                    contactos = DemoDAOMapping.GetContatctMapping(ds);
                }

            }
            catch (SqlException ex)
            {
                Logger.Error(ex);
                throw new ServiceDataException(ServiceDataException.DAO_METHOD_EXCEPTION,"DemoDAO" , ex);
            }
            catch (DataException ex)
            {
                Logger.Error(ex);
                throw new ServiceDataException(ServiceDataException.DAO_METHOD_EXCEPTION,
                          "DemoDAO", ex);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return contactos;
        }        

        
    }
}